import 'package:dio/dio.dart';

// GET 请求
void fetchData() async {
  final dio = Dio();
  final response = await dio.get(
    'https://jsonplaceholder.typicode.com/posts/1',
  );
  print(response.data);
}

// POST 请求
void postData() async {
  final dio = Dio();
  final response = await dio.post(
    'https://jsonplaceholder.typicode.com/posts',
    data: {'title': 'Flutter', 'body': 'Dio请求测试'},
  );
  print(response.data);
}
